#/usr/bin/env python

# Ellie, Behzad
def state2str(chess_board):
    # Behzad Vahedi - Elli
    b = ""
    for l in chess_board._board:
        b += "%s%s%s%s%s%s%s%s" % (l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7])
        
    d = (b,
    chess_board._turn,
    chess_board._white_king_castle,
    chess_board._white_queen_castle, 
    chess_board._black_king_castle,
    chess_board._black_queen_castle,
    chess_board._ep[0],
    chess_board._ep[1],
    chess_board._game_result,
    chess_board._fifty)
        
    #turn,wkc,wqc,bkc,bqc,epx,epy,game_result,fifty
    s = "%s%d%d%d%d%d%d%d%d:%d" % d
                            
    return s
    
 # Brian, Sandra
def getLastMove(chessboard):
    """
      Returns a tupple containing two tupples describing the move just made using the internal coordinates. 
      In the format ((from_x,from_y),(to_x,to_y))
      Ex. ((4,6),(4,4))
      Returns None if no moves has been made.
    """
    if chessboard._state_stack_pointer<=1: # No moves have happened yet
        return None
        
    chessboard.undo()
    move = chessboard._moves[chessboard._state_stack_pointer-1]        
    res = (move[1],move[2])
    chessboard.redo()
        
    return res
 
 
 
